package cn.xiyun.xiyuncc.service.impl;

import cn.xiyun.xiyuncc.domain.CourseChapter;
import cn.xiyun.xiyuncc.mapper.CourseChapterMapper;
import cn.xiyun.xiyuncc.service.ICourseChapterService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 课程章节 ， 一个课程，多个章节，一个章节，多个视频 服务实现类
 * </p>
 *
 * @author xiyun.maple
 * @since 2023-03-11
 */
@Service
public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, CourseChapter> implements ICourseChapterService {

    @Override
    public boolean insert(CourseChapter courseChapter) {
        EntityWrapper<CourseChapter> wrapper = new EntityWrapper<>();
        wrapper.eq("course_id",courseChapter.getCourseId());
        int i = super.selectCount(wrapper)+1;
        courseChapter.setNumber(i);
        return super.insert(courseChapter);
    }
}
